package com.syx.system.Controller.exam;

import com.syx.commoncore.Model.Result;
import com.syx.commoncore.Model.TableDataInfoResult;
import com.syx.system.Model.exam.DTO.ExamAddDTO;
import com.syx.system.Model.exam.DTO.ExamEditDTO;
import com.syx.system.Model.exam.DTO.ExamQueryDTO;
import com.syx.system.Model.exam.DTO.ExamQuestionAddDTO;
import com.syx.system.Model.exam.VO.ExamDetailVO;
import com.syx.system.Service.IExamService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/*竞赛相关的东西*/
@RestController
@RequestMapping("/exam")
public class ExamController {

    @Resource
    IExamService iExamService;


    @RequestMapping ("/list")
    public TableDataInfoResult list(@RequestBody ExamQueryDTO examQueryDTO){

        return iExamService.list(examQueryDTO);
    }

    @PostMapping("/add")
    //添加竞赛
    public Result<String> add(@Valid @RequestBody ExamAddDTO examAddDTO){

        return iExamService.add(examAddDTO);



    }


    //竞赛下面的新增题目
    @PostMapping("/question/add")
    public Result<Void> questionAdd( @Valid  @RequestBody ExamQuestionAddDTO examQuestionAddDTO){
        System.out.println(examQuestionAddDTO);

        return iExamService.questionAdd(examQuestionAddDTO);

    }

    @DeleteMapping("/question/delete")
    public Result<Void> questionDelete(Long examId,Long questionId){
        return iExamService.questionDelete(examId,questionId);

    }

    @GetMapping("/detail")
    public Result<ExamDetailVO> detail( Long examId){
        return iExamService.detail(examId);
    }

    //编辑题目
    @PostMapping("/edit")
    public Result<Void> edit(@Valid @RequestBody ExamEditDTO examEditDTO){

        return iExamService.edit(examEditDTO);

    }

    //删除竞赛，删除竞赛的时候也要把竞赛中对应的题目也删掉
    @DeleteMapping("/delete")
    public Result<Void> delete(Long examId){
        return iExamService.delete(examId);

    }

    @PostMapping("/publish")
    public Result<Void> publish(Long examId){
        return iExamService.publish(examId);

    }

    @PostMapping ("/cancelPublish")
    public Result<Void> cancelPublish(Long examId){
        return iExamService.cancelPublish(examId);

    }





}
